package com.example.demo.controller.video;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.example.demo.config.annotation.Token;
import com.example.demo.config.tool.MyJson;
import com.example.demo.model.EduVideoSource;
import com.example.demo.service.EduVideoSourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("video")
public class VideoController {
    @Autowired
    EduVideoSourceService eduVideoSourceService;

    @Token
    @RequestMapping("check")
    public JSONObject check(){
        List<EduVideoSource> all =  eduVideoSourceService.findAll();
        JSONArray jsonArray = MyJson.toJsonArray(all);
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("list", jsonArray);

        return jsonObject;
    }
}
